package service

import (
	"gitee.com/linxing_3/sr-core/domain/service/srvctx"
	"gitee.com/mkwchecking/sr-admin/apps/admin/entity"
)

// 获取当前角色对应的菜单列表
func (s *SysRole) GetCurrentRoleMenus(ctx srvctx.IContext) ([]*entity.SysMenu, error) {

	sessInfo, err := ctx.GetSessionInfo()
	if err != nil {
		return nil, err
	}

	roleMenus, err := s.repo.GetRoleMenus(sessInfo.RoleId, ctx.DaoScope())
	if err != nil {
		return nil, err
	}

	return entity.MakeMenuListRelation(roleMenus), nil
}
